//
//  TCMYdetailRouteTableViewCell.m
//  Project_B
//
//  Created by dllo on 15/11/26.
//  Copyright © 2015年 张闯. All rights reserved.
//

#import "TCMYdetailRouteTableViewCell.h"
#import "UIImageView+WebCache.h"
#define WIDTH [[UIScreen mainScreen] bounds].size.width / 375
#define HEIGHT [[UIScreen mainScreen] bounds].size.height / 667

@implementation TCMYdetailRouteTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.smallimage = [[UIImageView alloc]init];
        [self.contentView addSubview:self.smallimage];
        
        self.bigimage = [[UIImageView alloc]init];
        [self.contentView addSubview:self.bigimage];
        
        self.namelabel = [[UILabel alloc]init];
        [self.namelabel setFont:[UIFont systemFontOfSize:13]];
        self.namelabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.namelabel];
        
        self.timelabel = [[UILabel alloc]init];
        [self.timelabel setFont:[UIFont systemFontOfSize:13]];
        self.timelabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.timelabel];
        
        self.foollabel = [[UILabel alloc]init];
        [self.foollabel setFont:[UIFont systemFontOfSize:13]];
        self.foollabel.textColor = [UIColor grayColor];
        self.foollabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:self.foollabel];
        
        self.contextlabel = [[UILabel alloc]init];
        [self.contextlabel setFont:[UIFont systemFontOfSize:13]];
        self.contextlabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.contextlabel];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.smallimage.frame = CGRectMake(10*WIDTH, 10*HEIGHT, 40*WIDTH, 40*HEIGHT);
    self.namelabel.frame = CGRectMake(60*WIDTH, 13*HEIGHT, 150*WIDTH, 15*HEIGHT);
    self.timelabel.frame = CGRectMake(60*WIDTH, 40*HEIGHT, 150*WIDTH, 15*HEIGHT);
    self.foollabel.frame = CGRectMake(300*WIDTH, 10*HEIGHT, 60*WIDTH, 15*HEIGHT);
    self.contextlabel.frame = CGRectMake(10*WIDTH, 265*HEIGHT, 355*WIDTH, 40*HEIGHT);
    self.bigimage.frame = CGRectMake(10*WIDTH, 80*HEIGHT, 355*WIDTH, 180*HEIGHT);
}
- (void)setTemp:(TCdetailRoute *)temp
{
    if (self.temp != temp) {
        _temp = temp;
    }
    [self.smallimage sd_setImageWithURL:[NSURL URLWithString:temp.headicon] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];
    self.namelabel.text = temp.nickname;
    self.timelabel.text = temp.createdate;
    self.foollabel.text = [NSString stringWithFormat:@"%@楼",temp.floor];
    self.contextlabel.text = temp.content;
//    self.contextlabel.numberOfLines = 0;
    [self.contextlabel sizeToFit];
    if (temp.topic_image) {
        NSArray *dic = (NSArray *)temp.topic_image;
        [self.bigimage sd_setImageWithURL:[NSURL URLWithString:dic[0][@"image"]] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];
    }
}
+ (CGFloat)heightWithText:(NSString *)text fontSize:(NSInteger)fontsize
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:fontsize]};
    CGSize size = CGSizeMake(375 - 20, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
